package com.tvunetworks.device.extra.jms;

import com.tvunetworks.common.lang.service.route.bo.MqMessage;
import com.tvunetworks.common.service.mq.sender.MqMessageSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Ethan
 * @program:
 * @description:
 * @create: 2022/1/18 16:32
 **/
@Component
@Slf4j
public class MQProducers {
    /**
     *
     */
    public static final String DEVICE_ONLINE_REPORT = "online.report";
    /**
     *
     */
    public static final String DEVICE_LIVE_REPORT = "live.report";

    @Autowired
    private MqMessageSender mqMessageSender;

    /**
     * 设备状态变化时offline->online发消息给mq
     * @param message partyline消费
     */
    public void toRabbitMQByDeviceOnline(String message){
        log.error("Producer .send .message offline->online: {}", message );
        MqMessage mqMessage = new MqMessage(DEVICE_ONLINE_REPORT, message);
        mqMessageSender.execute(mqMessage, true);
    }

    /**
     * 设备状态变化时 online->live发消息给mq
     * @param message partyline消费
     */
    public void toRabbitMQByDeviceLive(String message){
        log.error("Producer .send .message  online->live: {}", message );
        MqMessage mqMessage = new MqMessage(DEVICE_LIVE_REPORT, message);
        mqMessageSender.execute(mqMessage, true);
    }
}
